#ifndef __I2CEMU_H__
#define __I2CEMU_H__

#include "soc/soc_gpio.h"
#include "plat/nonecopyable.h"
#include "device_def.h"
#include "buttondevice.h"
#include "soc/soc_gpio.h"
#include "soc/soc_exti.h"

/// @brief 模拟IIC 
class I2CEmu : public NoneCopyable
{
public:
    explicit I2CEmu();
    explicit I2CEmu(const GpioPortPin &sclPortPin, const GpioPortPin &sdaPortPin);
    virtual ~I2CEmu();

public:
    void Config(const GpioPortPin &sclPortPin, const GpioPortPin &sdaPortPin);
    void SetClkDelay(int us);

    bool SendByte(uint8_t dat);
    uint8_t ReadByte(bool ack);

private:
    void StartSignal();
    void StopSignal();
    bool WaitAckSignal();
    void AckSignal();
    void NAckSignal();

private:
    GpioPortPin m_SCLPortPin;
    GpioPortPin m_SDAPortPin;
    int m_clkDelay = 2; //us
};

#endif // __I2CEMU_H__
